Java Database Connectivity
part 11/17 · 28.8 KB total
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
String sql = "INSERT INTO emp1 VALUES ('pctb5361', 'kiril', 'john', 968666668)";
stmt.executeUpdate(sql);
System.out.println("Inserted records into the table...");
} catch (Exception e) {
e.printStackTrace();
}
}
}
JDBC drivers
JDBC drivers are client-side adapters (installed on the client machine, not on the server) that convert requests from Java programs to a protocol that the DBMS can understand.
Types
Commercial and free drivers provide connectivity to most relational-database servers. These drivers fall into one of the following types:
• Type 2 that calls database vendor native library on a client side. This code then talks to database over the network.
• Type 3, the pure-java driver that talks with the server-side middleware that then talks to the database.
• Type 4, the pure-java driver that uses database native protocol.
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────